<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>
        <c:if test="${empty(data.id)}">添加项目</c:if>
        <c:if test="${!empty(data.id)}">编辑项目</c:if>
    </title>
</head>

<body>

<div id="wrapper">
    <div class="gray-bg">
        <div class="row m-t-sm">
            <div class="col-lg-12">
                <ol class="breadcrumb f-fl">
                    <li>
                        <i class="fa fa-location-arrow"></i><a>人群管理</a>
                    </li>
                    <li class="active">
                        <strong>
                            添加互斥人群
                        </strong>
                    </li>
                </ol>
            </div>
        </div>
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                                <input  type="hidden" id="mid" name="mid" value="${mid}"/>


                                <div class="form-group"><label class="col-xs-3 f-tar control-label">人群</label>
                                    <div class="col-xs-7">
                                        <select class="form-control" name="itemId" id="itemId">
                                            <option value=""></option>
                                            <c:forEach var="item" items="${stars}">
                                                <option value="${item.id}" >${item.title}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>


                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-7 col-xs-offset-3">
                                        <button class="btn btn-primary" type="button" onclick="save()">保 存</button>
                                        <%--<a href="javascript:history.go(-1);" class="btn btn-white ">  取消</a>--%>
                                    </div>
                                </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="${ctx}/static/inspinia/js/plugins/layer/layer.js"></script>
<script>
    function save(){
        var itemId = $("#itemId").val();
        //var itemStatus = $("#itemStatus").val();
        var mid = $("#mid").val();

            $.ajax({
                method: "POST",
                url: "${ctx}/admin/crowd/additem",
                data: {
                    pid:mid,
                    hpid:itemId
                },
                dataType: "json",
                async: false,

                success: function(response) {
                        var id = response.id;
                        var itemTitle = response.itemtitle;
                        var itemStatus = response.sn;

                        var iframeId = parent.$("#pages_tabs li.active").find("a").attr("href");
                        parent.$(iframeId).find("iframe")[0].contentWindow.addItem(id ,itemTitle ,itemStatus);
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭


                }
            });

    }
</script>
</body>

</html>
